package org.ycx.upms.dao.auto;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.ycx.upms.dao.model.SecUser;
import org.ycx.upms.dao.model.SecUserExample;

import java.util.List;

public interface SecUserMapper {
    @SelectProvider(type=SecUserSqlProvider.class, method="countByExample")
    long countByExample(SecUserExample example);

    @DeleteProvider(type=SecUserSqlProvider.class, method="deleteByExample")
    int deleteByExample(SecUserExample example);

    @Delete({
        "delete from sec_user",
        "where UID = #{uid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer uid);

    @Insert({
        "insert into sec_user (LOGIN_NAME, PASSWD, ",
        "NICK_NAME, GENDER, ",
        "MOBILE, EMAIL, AVATER, ",
        "PWD_END_DATE, USE_STATE, ",
        "DEL_STATE, CREATE_TS, ",
        "CREATE_UID, UPDATE_TS, ",
        "UPDATE_UID)",
        "values (#{loginName,jdbcType=VARCHAR}, #{passwd,jdbcType=VARCHAR}, ",
        "#{nickName,jdbcType=VARCHAR}, #{gender,jdbcType=VARCHAR}, ",
        "#{mobile,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{avater,jdbcType=VARCHAR}, ",
        "#{pwdEndDate,jdbcType=DATE}, #{useState,jdbcType=VARCHAR}, ",
        "#{delState,jdbcType=VARCHAR}, #{createTs,jdbcType=DATE}, ",
        "#{createUid,jdbcType=INTEGER}, #{updateTs,jdbcType=DATE}, ",
        "#{updateUid,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="uid", before=false, resultType=Integer.class)
    int insert(SecUser record);

    @InsertProvider(type=SecUserSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="uid", before=false, resultType=Integer.class)
    int insertSelective(SecUser record);

    @SelectProvider(type=SecUserSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="UID", property="uid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="LOGIN_NAME", property="loginName", jdbcType=JdbcType.VARCHAR),
        @Result(column="PASSWD", property="passwd", jdbcType=JdbcType.VARCHAR),
        @Result(column="NICK_NAME", property="nickName", jdbcType=JdbcType.VARCHAR),
        @Result(column="GENDER", property="gender", jdbcType=JdbcType.VARCHAR),
        @Result(column="MOBILE", property="mobile", jdbcType=JdbcType.VARCHAR),
        @Result(column="EMAIL", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="AVATER", property="avater", jdbcType=JdbcType.VARCHAR),
        @Result(column="PWD_END_DATE", property="pwdEndDate", jdbcType=JdbcType.DATE),
        @Result(column="USE_STATE", property="useState", jdbcType=JdbcType.VARCHAR),
        @Result(column="DEL_STATE", property="delState", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER)
    })
    List<SecUser> selectByExample(SecUserExample example);

    @Select({
        "select",
        "UID, LOGIN_NAME, PASSWD, NICK_NAME, GENDER, MOBILE, EMAIL, AVATER, PWD_END_DATE, ",
        "USE_STATE, DEL_STATE, CREATE_TS, CREATE_UID, UPDATE_TS, UPDATE_UID",
        "from sec_user",
        "where UID = #{uid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="UID", property="uid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="LOGIN_NAME", property="loginName", jdbcType=JdbcType.VARCHAR),
        @Result(column="PASSWD", property="passwd", jdbcType=JdbcType.VARCHAR),
        @Result(column="NICK_NAME", property="nickName", jdbcType=JdbcType.VARCHAR),
        @Result(column="GENDER", property="gender", jdbcType=JdbcType.VARCHAR),
        @Result(column="MOBILE", property="mobile", jdbcType=JdbcType.VARCHAR),
        @Result(column="EMAIL", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="AVATER", property="avater", jdbcType=JdbcType.VARCHAR),
        @Result(column="PWD_END_DATE", property="pwdEndDate", jdbcType=JdbcType.DATE),
        @Result(column="USE_STATE", property="useState", jdbcType=JdbcType.VARCHAR),
        @Result(column="DEL_STATE", property="delState", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER)
    })
    SecUser selectByPrimaryKey(Integer uid);

    @UpdateProvider(type=SecUserSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") SecUser record, @Param("example") SecUserExample example);

    @UpdateProvider(type=SecUserSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") SecUser record, @Param("example") SecUserExample example);

    @UpdateProvider(type=SecUserSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(SecUser record);

    @Update({
        "update sec_user",
        "set LOGIN_NAME = #{loginName,jdbcType=VARCHAR},",
          "PASSWD = #{passwd,jdbcType=VARCHAR},",
          "NICK_NAME = #{nickName,jdbcType=VARCHAR},",
          "GENDER = #{gender,jdbcType=VARCHAR},",
          "MOBILE = #{mobile,jdbcType=VARCHAR},",
          "EMAIL = #{email,jdbcType=VARCHAR},",
          "AVATER = #{avater,jdbcType=VARCHAR},",
          "PWD_END_DATE = #{pwdEndDate,jdbcType=DATE},",
          "USE_STATE = #{useState,jdbcType=VARCHAR},",
          "DEL_STATE = #{delState,jdbcType=VARCHAR},",
          "CREATE_TS = #{createTs,jdbcType=DATE},",
          "CREATE_UID = #{createUid,jdbcType=INTEGER},",
          "UPDATE_TS = #{updateTs,jdbcType=DATE},",
          "UPDATE_UID = #{updateUid,jdbcType=INTEGER}",
        "where UID = #{uid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(SecUser record);
}